package com.demo.house.controller;


import com.demo.house.common.Result;
import com.demo.house.entity.Appointment;
import com.demo.house.service.AppointmentService;
import com.demo.house.vo.request.RequestAppointmentVo;
import com.demo.house.vo.response.ResponseAppointmentSelectLandlordVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/appointment/")
public class AppointmentController {


    @Autowired
    private AppointmentService appointmentService;

    /**
     * 新增预约
     * @param appointmentVo
     * @return
     */
    @PostMapping("insertAppointment")
    public Result insertAppointment(@RequestBody RequestAppointmentVo appointmentVo){
        return Result.getSuccess().setData(appointmentService.insertSelective(appointmentVo));
    }


    /**
     * 房东查询预约
     * @param id
     * @return
     */
    @GetMapping("selectLandlord/{id}")
    public Result selectLandlord(@PathVariable Integer id){
        return Result.getSuccess().setData(appointmentService.selectByUserIdList(id));
    }

    /**
     * 租客根据UserId查询
     * @param id
     * @return
     */
    @GetMapping("selectUserId/{id}")
    public Result selectUserId(@PathVariable Integer id){
        return Result.getSuccess().setData(appointmentService.selectUserId(id));
    }


    /* *//**
     * 审核预约
     * @param id
     * @return
     *//*
    @GetMapping("Review/{id}")
    public Result getReview(@PathVariable Integer id){
        Appointment app=new Appointment();
        app.setId(id);
        int review = appointmentService.Review(app);
        return Result.getSuccess().setData(review);
    }
*/

    /**
     * 同意预约
     * @param id
     * @return
     */
    @PutMapping("/reviewReservation/{id}")
    public Result reviewReservation(@PathVariable Integer id){
        appointmentService.ReviewReservation(id);
        return Result.getSuccess().setMsg("操作成功");
    }

    /**
     * 不同意预约
     * @param id
     * @return
     */
    @PutMapping("/disagreeReservation/{id}")
    public Result disagreeReservation(@PathVariable Integer id){
        appointmentService.disagreeReservation(id);
        return Result.getSuccess().setMsg("操作成功");
    }
}
